<?php
require_once("../data/db_connection.php");
require_once("../constants.php");
require_once("../Utils.php");

$db = new db();

$user_id = getFinalValue($_POST[PARAM_USER_ID]);
$relation_state = getFinalValue($_POST[PARAM_RELATION_STATE]);

$arr = array();

$sql = "SELECT * FROM pTableRelation WHERE pUserId = " . $user_id . " and pRelationState = " . $relation_state;

if($result = $db->query($sql)) {
	while($row = $result->fetch_assoc()) {	
		$arr[] = $row;
	}
}

$str = json_encode($arr);

echo json_encode($str);
?>